
#include<sys/epoll.h>

#include "Poller.h"

// epoll create
// epoll ctl
// epoll wait

/**
 * 
 *              EventLoop. -> poller.poll
 *        ChannelList       Poller
 *                         ChannelMap
 * 
 */

class EpollPoller : public Poller
{

public:
    EpollPoller(EventLoop *loop);
    ~EpollPoller();

    Timestamp poll(int timeout, ChannelList *activateChannels);
    void updateChannel(Channel *c);
    void removeChannel(Channel *c);

private:
    static const int kInitEventListSizze = 16;
    void update(int opearete, Channel *channel);

    void fillActiveChannels(int numEvents, ChannelList *activeChannels) const;

    // epoll底层产生的特殊的文件系统
    int epollfd_;

    // 保存发生事件的
    using EventList = std::vector<epoll_event>;
    EventList events_;
};